package com.wyj.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.net.HttpCookie;
import java.util.IllformedLocaleException;

/**
 * @author 王永杰
 * @Description 描述该类的做什么用
 * @since 2022/7/7
 */
public class CookieUtil {


    /**
    * @Description 这里的话 是主要对 Cookie中存的  ticket进行提取
    * @param
    * @retuen 返回值说明
    * @throws
    * @author 创建人
    * @since 创建日期
    */

    public static String getValue(HttpServletRequest request,String name) {
        if (name == null || request == null) {
            IllegalArgumentException exception = new IllegalArgumentException("参数为空");
            String s = exception.toString();
            return s;
        }

        Cookie[] cookies = request.getCookies();

        if (cookies != null) {
            for (Cookie cookie : cookies) {

                if (cookie.getName().equals(name)) {
                    return cookie.getValue();
                }
            }
        }

        return null;
    }

}
